Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: aws_iot_thing #3521

Merged
merged 1 commit into from
Mar 1, 2018
Merged

New Resource: aws_iot_thing #3521

merged 1 commit into from
Mar 1, 2018

Conversation

radeksimko
Copy link
Member

TF_ACC=1 go test ./aws -v -run=TestAccAWSIotThing_ -timeout 120m
=== RUN   TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (59.38s)
=== RUN   TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (377.55s)
=== RUN   TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (33.18s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	470.151s

@radeksimko radeksimko added new-resource Introduces a new resource. service/iot Issues and PRs that pertain to the iot service. labels Feb 25, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 25, 2018
@radeksimko radeksimko mentioned this pull request Feb 25, 2018
7 tasks
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As usual, this is looking pretty good! Some minor comments below then should be ready to ship. 😄

Currently passing tests for me:

make testacc TEST=./aws TESTARGS='-run=TestAccAWSIotThing_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIotThing_ -timeout 120m
=== RUN   TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (10.59s)
=== RUN   TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (329.40s)
=== RUN   TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (8.98s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	349.011s

}

d.SetId(*out.ThingName)
d.Set("arn", out.ThingArn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Extraneous set here

Delete: resourceAwsIotThingDelete,

Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we could use the passthrough importer here unless I'm missing something 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a piece of code I somehow forgot here as I was refactoring the CRUD.

log.Printf("[DEBUG] Received IoT Thing: %s", out)

d.Set("arn", out.ThingArn)
d.Set("attributes", aws.StringValueMap(out.Attributes))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

log.Printf("[DEBUG] Deleting IoT Thing: %s", params)

_, err := conn.DeleteThing(params)
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return nil on iot.ErrCodeResourceNotFoundException here?

})
}

func testAccCheckAWSIotThingDestroy(s *terraform.State) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there also be an associated testAccCheckAWSIotThingExists?

}

_, err := conn.DescribeThing(params)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we flip this around to return nil on iot.ErrCodeResourceNotFoundException error and return the actual error on others (e.g. permission errors)?

Creates and manages an AWS IoT Thing.
---

# aws_iot_thing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ## Import documentation

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 26, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 1, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 1, 2018
@radeksimko
Copy link
Member Author

@bflad PTAL, I believe I addressed all your comments 😉

=== RUN   TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (18.44s)
=== RUN   TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (351.33s)
=== RUN   TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (19.77s)

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 1, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one minor thing that you can turbo merge in to fix an error message in the testing.

make testacc TEST=./aws TESTARGS='-run=TestAccAWSIotThing_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIotThing_ -timeout 120m
=== RUN   TestAccAWSIotThing_basic
--- PASS: TestAccAWSIotThing_basic (9.73s)
=== RUN   TestAccAWSIotThing_full
--- PASS: TestAccAWSIotThing_full (338.24s)
=== RUN   TestAccAWSIotThing_importBasic
--- PASS: TestAccAWSIotThing_importBasic (8.32s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	356.333s

}

_, err := conn.DescribeThing(params)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw shucks - just missing a return err in here, otherwise we print out the wrong message below

@bflad bflad added this to the v1.11.0 milestone Mar 1, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 1, 2018
@radeksimko radeksimko merged commit 7ee86ba into master Mar 1, 2018
@radeksimko radeksimko deleted the f-iot-thing branch March 1, 2018 22:34
@bflad
Copy link
Contributor

bflad commented Mar 9, 2018

This has been released in version 1.11.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. service/iot Issues and PRs that pertain to the iot service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants